﻿using System.Collections.Generic;
using Might.Infrastructure.ModelicaDOM;

namespace Might.Modelica.Annotations.Graphics {
    ///<summary>
    ///</summary>
    [Mapping("CoordinateSystem")]
    public class CoordinateSystem  {
        ///<summary>
        ///</summary>
        public CoordinateSystem() {
            Extent = new GraphicsExtent();
            PreserveAspectRatio = true;
            initialScale = 0.1;
            grid = new List<double> {1, 1};
        }

        ///<summary>
        ///</summary>
        ///<param name="extent"></param>
        ///<param name="preserveAspectRatio"></param>
        ///<param name="initialScale"></param>
        ///<param name="grid"></param>
        public CoordinateSystem(
            GraphicsExtent extent,
            bool preserveAspectRatio,
            double initialScale,
            List<double> grid) {
            Extent = extent;
            PreserveAspectRatio = preserveAspectRatio;
            this.initialScale = initialScale;
            this.grid = grid;
        }


        ///<summary>
        ///</summary>
        [Mapping("extent")]
        public GraphicsExtent Extent {
            get {
                return _extent;
            } set {
                _extent = value;
            }
        }

        private GraphicsExtent _extent;

        ///<summary>
        ///</summary>
        [Mapping("preserveAspectRatio")]
        public bool PreserveAspectRatio { get; set; }

        ///<summary>
        ///</summary>
        [Mapping("initialScale")]
        public double initialScale { get; set; }

        ///<summary>
        ///</summary>
        [Mapping("grid")]
        public List<double> grid { get; set; }

        [UnknownMapping]
        public List<object> UnknownItems { get; set; }

        public bool IsDefault {
            get {
                return Extent.IsDefault &&
                    PreserveAspectRatio &&
                        initialScale == 0.1 &&
                            grid.Count == 0;  // TODO what is default for grid?
            }
        }
    }
}